package com.sk.bilibili.generate.info;

import com.sk.bilibili.generate.utils.Tool;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 邵康
 * @date 2021/11/22 18:30
 */
@Data
public class ClassInfo {

    private String name;
    private List<FieldInfo> fieldInfos;
    private Boolean hasFile;

    public ClassInfo(String name) {
        this.name = transition(name);
        fieldInfos=new ArrayList<>();
        hasFile=false;
    }

    private String transition(String name) {
        Tool tool = new Tool();
        String[] split = name.split("_");
        StringBuilder builder=new StringBuilder();
        builder.append(split[0]);
        for (int i = 1; i < split.length; i++) {
            builder.append(tool.upperFirst(split[i]));
        }
        return builder.toString();
    }

    public void addFieldInfo(FieldInfo fieldInfo){
        if(!hasFile&&fieldInfo.getFile()){
            hasFile=true;
        }
        fieldInfos.add(fieldInfo);
    }

}
